package com.lanou.myapp.progressdialog;

import android.content.Context;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.widget.TextView;

import com.lanou.myapp.R;
import com.lanou.myapp.circle.SpinnerLoader;

/**
 * Created by dllo on 16/1/23.
 */
public class Dialog extends android.app.Dialog{
    private TextView textView;
    private SpinnerLoader spinnerLoader;
    private int mResid;
    private Context context;
    private AnimationDrawable mAnimation;
    private String mLoadingTip;

    public Dialog(Context context,String content) {
        super(context);
        this.context = context;
        this.mLoadingTip = content;
        setCanceledOnTouchOutside(true);
    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        initData();
        initView();
        initData();
    }

    private void initData() {


//        spinnerLoader.setBackgroundResource(mResid);
        // 通过ImageView对象拿到背景显示的AnimationDrawable, 帧动画
//        mAnimation = (AnimationDrawable) spinnerLoader.getBackground();
//        // 为了防止在onCreate方法中只显示第一帧的解决方案之一
//        spinnerLoader.post(new Runnable() {
//            @Override
//            public void run() {
//                mAnimation.start();
//            }
//        });
        textView.setText(mLoadingTip);
    }


    public void setContent(String str) {
        textView.setText(str);
    }


    private void initView() {
        setContentView(R.layout.dialog_fragment);
        textView = (TextView) findViewById(R.id.one);
        spinnerLoader = (SpinnerLoader) findViewById(R.id.two);

    }

}
